package com.ghost.manager
{
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import com.ghost.event.SocketEvent;
	
	import flash.utils.ByteArray;
	import flash.utils.Endian;

	/**
	 * 分发后台数据 
	 * @author ghost
	 */	
	public class Dispense_manager
	{
		private static var instance:Dispense_manager;
		public static function getinstance():Dispense_manager
		{
			if(instance != null)instance = new Dispense_manager();
			return instance;
		}
		public function Dispense_manager()
		{
		}
		/**
		 * 分发数据(协议头+数据体)
		 * @param bytes
		 */		
		public function init(bytes:ByteArray):void
		{
			var data_bt:ByteArray = new ByteArray();//存放数据体
			data_bt.endian = Endian.LITTLE_ENDIAN;
			var event:SocketEvent = new SocketEvent(bytes.readShort().toString());
			bytes.readBytes(data_bt,0,bytes.bytesAvailable);
			event.data = data_bt;
			CairngormEventDispatcher.getInstance().dispatchEvent(event);
		}
		
	}
}